<?php

class UserMain extends AppModel
{
	var $primaryKey = 'Id';
 
	// Nous n'utiliserons pas de table dans la base
	//var $useTable = false;
 
	// Nous donnons donc à Cake la structure d'un enregistrement
	var $_schema = array(
		'Login' => array(
			'type' => 'string',
			'length' => 15
		),
		'Name' => array(
			'type' => 'string',
			'length' => 40
		),
		'Firstname' => array(
			'type' => 'string',
			'length' => 40
		),
		'Email' => array(
			'type' => 'string',
			'length' => 50
		),
		'Passwd' => array(
			'type' => 'string',
			'length' => 50
		),
		'Nationality' => array(
			'type' => 'string',
			'length' => 2
		),
	);
 
	// Règles de validation des données
	var $validate = array(
	
		'Login' => array(

			'isUnique' => array(
				'rule' => 'isUnique',
				'message' => 'This username has already been taken.'
            ),
			'alphaNumeric' => array(
                'rule' => 'alphaNumeric',
                'required' => true,
                'message' => 'Chiffres et lettres uniquement !'
            ),
			'between' => array(
                'rule' => array('between', 3, 15),
                'message' => 'Entre 3 et 15 caractères'
            ),
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'required' => true,
				'allowEmpty' => false,
				'message' => "Le Login doit être renseigné."
            ),
		),
		'InternetProtocol' => array(
			'rule' => 'ip',
			'message' => 'Please supply a valid IP address.'
		),

		'Email' => array(
		    'email' => array(
				'rule' => 'isUnique',
				'message' => 'This email has already been taken.'
            ),
			'isUnique' => array(
				'rule' => 'email',
				'required' => true,
				'allowEmpty' => false,
				'message' => "Vous devez saisir une adresse email valide."
            ),
		),

	

		'Name' => array(
			'between' => array(
                'rule' => array('between', 2, 40),
                'message' => 'Between 2 and 40 char'
            ),
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'required' => true,
				'allowEmpty' => false,
				'message' => "Your name must be set."
            ),
		),
		'FirstName' => array(
		
			'between' => array(
                'rule' => array('between', 2, 40),
                'message' => 'Between 2 and 40 char'
            ),
			'notEmpty' => array(
				'rule' => 'notEmpty',
				'required' => true,
				'allowEmpty' => false,
				'message' => "Your firstname must be set."
            ),

		),



		'Password' => array(

				'rule' => 'notEmpty',
				'required' => true,
				'allowEmpty' => false,
				'message' => "Your firstname must be set."
        ),
	

		
	);
	
	/*
	var $belongsTo = array(
        'GeolocalisationCountry' => array(
            'className'    => 'GeolocalisationCountry',
            'foreignKey'    => 'Nationality'
        )
    );  
*/
	


	
	
}

?>